Task = {
	//建立付費案件
	TaskCreate:{
		check:function(form){
			if(form.fromLang.value == form.toLang.value){
				Message.show("msg-wrong-format", 400, "格式錯誤", "翻譯語言的來源與目的不得相同", Message.BUTTON_OK);
				return false;
			}
			
			if(form.price.value == ""){
				Message.show("msg-wrong-format", 400, "格式錯誤", "請填寫案件價格", Message.BUTTON_OK);
				return false;
			}
			if(form.price.value.search(/[^0-9]/) > -1){
				Message.show("msg-wrong-format", 400, "格式錯誤", "案件價格格式錯誤", Message.BUTTON_OK);
				return false;
			}
			if(parseInt(form.price.value) < 100 || parseInt(form.price.value) > 25000){
				Message.show("msg-wrong-format", 400, "格式錯誤", "案件價格必須介於 NTD 100 元至 25000 元之間", Message.BUTTON_OK);
				return false;
			}
			if(parseInt(form.price.value) > parseInt(form.money.value)){
				Message.show("msg-wrong-format", 400, "格式錯誤", "帳戶餘額不足", Message.BUTTON_OK);
				return false;
			}
			
			if(form.year.selectedIndex == 0 || form.month.selectedIndex == 0 || form.date.selectedIndex == 0){
				Message.show("msg-wrong-format", 400, "格式錯誤", "請選擇案件截止日期", Message.BUTTON_OK);
				return false;
			}
			
			if(form.domain.value == ""){
				Message.show("msg-wrong-format", 400, "格式錯誤", "請填寫翻譯案件領域", Message.BUTTON_OK);
				return false;
			}
			if(form.domain.value.length > 30){
				Message.show("msg-wrong-format", 400, "格式錯誤", "翻譯案件領域內容不得超過 30 字元", Message.BUTTON_OK);
				return false;
			}
			
			if(form.description.value == ""){
				Message.show("msg-wrong-format", 400, "格式錯誤", "請填寫翻譯案件說明", Message.BUTTON_OK);
				return false;
			}
			if(form.description.value.length > 300){
				Message.show("msg-wrong-format", 400, "格式錯誤", "翻譯案件說明不得超過 300 字元", Message.BUTTON_OK);
				return false;
			}
			
			if(form.content.value == ""){
				Message.show("msg-wrong-format", 400, "格式錯誤", "請填寫翻譯原文", Message.BUTTON_OK);
				return false;
			}
			if(form.content.value.length > 50000){
				Message.show("msg-wrong-format", 400, "格式錯誤", "翻譯原文不得超過 50000 字元", Message.BUTTON_OK);
				return false;
			}
			
			if(!form.agree.checked){
				Message.show("msg-wrong-format", 400, "錯誤", "請先點擊同意注意事項", Message.BUTTON_OK);
				return false;
			}
			return true;
		},
		create:function(form){
			if(Task.TaskCreate.check(form)){
				var send = function(){
					Message.show("msg-task-creating", 400, "案件建立中", Ajax.loadingImg);
					Ajax.sendRequest(
						"post", "/exe/member/CreateTask", 
						"from_lan=" + form.fromLang.value + "&to_lan=" + form.toLang.value
							+ "&domain=" + encodeURIComponent(form.domain.value) 
							+ "&description=" + encodeURIComponent(form.description.value)
							+ "&content=" + encodeURIComponent(form.content.value)
							+ "&price=" + form.price.value + "&publish_time=" + form.now.value
							+ "&dead_time="
							+ new Date(
								parseInt(form.year.options[form.year.selectedIndex].value),
								parseInt(form.month.options[form.month.selectedIndex].value) - 1,
								parseInt(form.date.options[form.date.selectedIndex].value), 23, 59, 59).getTime(), 
						true, 
						function(req){
							Message.hide("msg-task-creating");
							var result = req.getResponseHeader("result");
							if(result == "true"){
								Message.show(
									"msg-task-result", 400, "建立成功", "案件已成功建立", 
									new Message.Button("確定", function(){document.location.href='/task/task-list.jsp';})
								);
							}else{
								Message.show("msg-task-result", 400, "建立失敗", "請稍後重試或聯絡客服", Message.BUTTON_OK);
							}
						}
					);
				}
				
				Message.show(
					"msg-task-create-confirm", 400, "確認建立付費案件", 
					"是否確定建立付費案件？<br/>一旦建立付費案件，您的帳戶將先行扣除案件價格。",
					new Message.Button("確定", send), Message.BUTTON_CANCEL
				);
			}
		},
		setDateSelecter:function(formId, selectObj){
			var form = document.getElementById(formId);
			var now = form.now.value;
			now = now ? new Date(parseInt(now)) : new Date();
			var deadline = new Date(now.getTime());
			deadline.setDate(now.getDate() + 180);
			
			if(selectObj == form.year){	//Set month
				Task.TaskCreate.clearSelect(form.month);
				Task.TaskCreate.clearSelect(form.date);
			
				var yearSelect = parseInt(form.year.options[form.year.selectedIndex].value);
				if(yearSelect){
					if(yearSelect == now.getFullYear()){
						if(deadline.getMonth() < now.getMonth()){
							for(var i = now.getMonth() + 1; i <= 12; i++){
								Utility.createElement("option", {innerHTML:i, value:i}, null, null, form.month);
							}
						}else{
							for(var i = now.getMonth() + 1; i <= deadline.getMonth() + 1; i++){
								Utility.createElement("option", {innerHTML:i, value:i}, null, null, form.month);
							}
						}
					}else{
						for(var i = 1; i <= deadline.getMonth() + 1; i++){
							Utility.createElement("option", {innerHTML:i, value:i}, null, null, form.month);
						}
					}
				}
			}else if(selectObj == form.month){	//Set date
				Task.TaskCreate.clearSelect(form.date);
			
				var yearSelect = parseInt(form.year.options[form.year.selectedIndex].value);
				var monthSelect = parseInt(form.month.options[form.month.selectedIndex].value);
				if(yearSelect && monthSelect){
					var minDate = (monthSelect == now.getMonth() + 1) ? now.getDate() + 1 : 1;
					var maxDate = 
						(monthSelect == deadline.getMonth() + 1) 
						? deadline.getDate() : MyDate.getMaxDateInMonth(yearSelect, monthSelect);
					for(var i = minDate; i <= maxDate; i++){
						Utility.createElement("option", {innerHTML:i, value:i}, null, null, form.date);
					}
				}
			}else{	//Set year & init date now
				var yearValue = now.getFullYear();
				Utility.createElement("option", {innerHTML:yearValue, value:yearValue}, null, null, form.year);
				if(deadline.getMonth() < now.getMonth()){
					Utility.createElement("option", {innerHTML:yearValue + 1, value:yearValue + 1}, null, null, form.year);
				}
				
				document.getElementById("year-now").innerHTML = yearValue;
				document.getElementById("month-now").innerHTML = now.getMonth() + 1;
				document.getElementById("date-now").innerHTML = now.getDate();
				form.now.value = now.getTime();
			}
		},
		clearSelect:function(select){
			while(select.length != 1){
				select.removeChild(select.options[select.length - 1]);
			}
		},
		countLetter:function(textareaObj){
			var count = document.getElementById("letter-count");
			count.innerHTML = textareaObj.value.length;
		},
		countWord:function(textareaObj){
			var count = document.getElementById("word-count");
			var lan = document.getElementById("from-lang");
			lan = lan.options[lan.selectedIndex].value;
			if(lan == 1 || lan == 3 || lan == 4){ // 中日韓為方塊字計數
				count.innerHTML = textareaObj.value.replace(/\s+/g, "").length;
			}else{
				var text = textareaObj.value.replace(/\s+/g, " "); // 先將連續的空白字元換成一個空白
				var len = text.replace(/\s/g, "").length; // 將空白拿掉後的長度
				if(len == 0){ // 相減得到拼音字字數
					count.innerHTML = "0"; 
				}else{
					count.innerHTML = text.length - len + 1;
				}
			}
		}
	},
	//提出接案申請
	applyTask:function(taskId){
		if(!taskId){
			return;
		}else if(taskId == -1){
			Message.show("msg-access-denied", 400, "權限不足", "請先登入以提出接案申請", Message.BUTTON_OK);
			return;
		}else if(taskId == -2){
			Message.show("msg-access-denied", 400, "權限不足", "您必須先通過 E-Mail 驗證才能提出接案申請", Message.BUTTON_OK);
			return;
		}else if(taskId == -3){
			Message.show("msg-access-denied", 400, "權限不足", "您必須先建立譯者資料才能提出接案申請", Message.BUTTON_OK);
			return;
		}
		
		var send = function(){
			Message.show("msg-apply-task-processing", 400, "系統處理中", Ajax.loadingImg);
			Ajax.sendRequest(
				"post", "/exe/member/ApplyTask", "id=" + taskId , true, 
				function(req){
					Message.hide("msg-apply-task-processing");
					var result = req.getResponseHeader("result");
					if(result == 1){
						Message.show("msg-apply-task-result", 400, "處理成功", "您的申請已成功送出", Button.buttonReload)
					}else{
						Message.show("msg-apply-task-result", 400, "處理失敗", "請稍後重試或聯絡客服", Message.BUTTON_OK);
					}
				}
			);
		}
		
		Message.show(
			"msg-apply-task-confirm", 400, "確認提出接案申請", 
			"是否確定提出接案申請？<br/>點擊確定表示您已完全了解<br/>本站的【<a target='_blank' href='/image/task-flow.png'>付費案件詳細流程</a>】說明。",
			new Message.Button("確定", send), Message.BUTTON_CANCEL
		);
	},	
	//撤回接案申請
	unapplyTask:function(taskId){	
		if(!taskId){
			return;
		}
		
		var send = function(){
			Message.show("msg-unapply-task-processing", 400, "系統處理中", Ajax.loadingImg);
			Ajax.sendRequest(
				"post", "/exe/member/UnapplyTask", "id=" + taskId , true, 
				function(req){
					Message.hide("msg-unapply-task-processing");
					var result = req.getResponseHeader("result");
					if(result == 1){
						Message.show("msg-unapply-task-result", 400, "處理成功", "您的的接案申請已成功撤回", Button.buttonReload);
					}else{
						Message.show("msg-unapply-task-result", 400, "處理失敗", "請稍後重試或聯絡客服", Message.BUTTON_OK);
					}
				}
			);
		}
		
		Message.show(
			"msg-apply-task-confirm", 400, "確認撤回接案申請", "是否確定撤回接案申請？<br/>撤回接案申請後，您仍可重新提出申請。",
			new Message.Button("確定", send), Message.BUTTON_CANCEL
		);
	},
	//案主選定接案譯者
	assignTask:function(taskId, translatorId){
		if(!taskId || !translatorId){
			return;
		}
		
		var assign = function(){
			Message.show("msg-assign-task-processing", 400, "系統處理中", Ajax.loadingImg);
			Ajax.sendRequest(
				"post", "/exe/member/AssignTask", "id=" + taskId + "&translator=" + translatorId , true, 
				function(req){
					Message.hide("msg-assign-task-processing");
					var result = req.getResponseHeader("result");
					if(result == 1){
						Message.show(
							"msg-assign-task-result", 400, "處理成功", 
							"案件媒合成功<br/>系統已通知接案譯者開始翻譯", 
							Button.buttonReload
						);
					}else{
						Message.show(
							"msg-apply-task-result", 400, "處理失敗", "請稍後重試或聯絡客服", Message.BUTTON_OK);
					}
				}
			);
		};
		
		Message.show(
			"msg-pick-response-confirm", 500, "確認選定接案譯者", 
			"您確定要選定此譯者為接案譯者嗎？<br/>一旦選定後案件即媒合成功，接案譯者將無法更改。",
			new Message.Button("確定", assign), Message.BUTTON_CANCEL
		);
	},
	//接案者上傳譯文
	updateTranslation:function(taskId, textareaId){
		if(!taskId || !textareaId){
			return;
		}
		var translation = document.getElementById(textareaId).value;
		if(translation == ""){
			Message.show("msg-wrong-format", 400, "格式錯誤", "請填寫翻譯譯文", Message.BUTTON_OK);
			return;
		}
		if(translation.length > 500000){
			Message.show("msg-wrong-format", 400, "格式錯誤", "翻譯譯文不得超過 500000 字", Message.BUTTON_OK);
			return;
		}
		
		Message.show("msg-update-translation-processing", 400, "系統處理中", Ajax.loadingImg);
		Ajax.sendRequest(
			"post", "/exe/member/UpdateTranslation", "id=" + taskId + "&translation=" + encodeURIComponent(translation), true, 
			function(req){
				Message.hide("msg-update-translation-processing");
				var result = req.getResponseHeader("result");
				if(result == 1){
					Message.show("msg-update-translation-result", 400, "處理成功", "已成功儲存譯文", Button.buttonReload);
				}else{
					Message.show("msg-update-translation-result", 400, "處理失敗", "請稍後重試或聯絡客服", Message.BUTTON_OK);
				}
			}
		);
	},
	//接案者交件譯文
	confirmTranslation:function(taskId, textareaId){
		if(!taskId || !textareaId){
			return;
		}
		var translation = document.getElementById(textareaId).value;
		if(translation == ""){
			Message.show("msg-wrong-format", 400, "格式錯誤", "請填寫翻譯譯文", Message.BUTTON_OK);
			return;
		}
		
		var assign = function(){
			Message.show("msg-confirm-translation-processing", 400, "系統處理中", Ajax.loadingImg);
			Ajax.sendRequest(
				"post", "/exe/member/ConfirmTranslation", "id=" + taskId + "&translation=" + encodeURIComponent(translation), true, 
				function(req){
					Message.hide("msg-confirm-translation-processing");
					var result = req.getResponseHeader("result");
					if(result == 1){
						Message.show("msg-confirm-translation-result", 400, "處理成功", "已成功交件", Button.buttonReload);
					}else{
						Message.show("msg-confirm-translation-result", 400, "處理失敗", "請稍後重試或聯絡客服", Message.BUTTON_OK);
					}
				}
			);
		}
		
		Message.show(
			"msg-confirm-translation-confirm", 500, "確認交件", 
			"是否確定交件？<br/>一旦交件，將無法再做任何修改。<br/>譯文將交由案主審閱。",
			new Message.Button("確定", assign), Message.BUTTON_CANCEL
		);
	},
	//撤回逾期案件
	revokeTask:function(taskId){
		if(!taskId){
			return;
		}else if(taskId == -1){
			Message.show(
				"msg-revoke-task-error", 400, "案件尚未逾期", "案件必須在逾期後才能撤回。",	Message.BUTTON_OK
			);
			return;
		}
		
		var revoke = function(){
			Message.show("msg-revoke-task-processing", 400, "系統處理中", Ajax.loadingImg);
			Ajax.sendRequest(
				"post", "/exe/member/RevokeTask", "id=" + taskId, true, 
				function(req){
					Message.hide("msg-revoke-task-processing");
					var result = req.getResponseHeader("result");
					if(result == 1){
						Message.show("msg-revoke-task-result", 400, "處理成功", "已成功撤回案件", Button.buttonReload);
					}else{
						Message.show("msg-revoke-task-result", 400, "處理失敗", "請稍後重試或聯絡客服", Message.BUTTON_OK);
					}
				}
			);
		}
		
		Message.show(
			"msg-revoke-task-confirm", 500, "確認撤回案件", 
			"是否確定撤回案件？<br/>一旦撤回案件，案件款項將全數退還。",
			new Message.Button("確定", revoke), Message.BUTTON_CANCEL
		);
	},	
	//案件成交
	acceptTranslation:function(taskId){
		if(!taskId){
			return;
		}
		
		var accept = function(){
			Message.show("msg-accept-translation-processing", 400, "系統處理中", Ajax.loadingImg);
			Ajax.sendRequest(
				"post", "/exe/member/AcceptTranslation", "id=" + taskId, true, 
				function(req){
					Message.hide("msg-accept-translation-processing");
					var result = req.getResponseHeader("result");
					if(result == 1){
						Message.show(
							"msg-accept-translation-result", 400, "處理成功", 
							"案件已成交。<br/><span class='mark-red'>提醒您：若需進行案件申訴，請在三天內提出。</span>", 
							Button.buttonReload
						);
					}else{
						Message.show("msg-accept-translation-result", 400, "處理失敗", "請稍後重試或聯絡客服", Message.BUTTON_OK);
					}
				}
			);
		}
		
		Message.show(
			"msg-accept-translation-confirm", 500, "確認案件成交", 
			"是否確定成交案件？<br/>成交後，您將取得全部譯文，並支付所有款項給譯者。",
			new Message.Button("確定", accept), Message.BUTTON_CANCEL
		);
	},	
	//案件退件
	rejectTranslation:function(taskId){
		if(!taskId){
			return;
		}
		
		var reject = function(){
			Message.show("msg-reject-translation-processing", 400, "系統處理中", Ajax.loadingImg);
			Ajax.sendRequest(
				"post", "/exe/member/RejectTranslation", "id=" + taskId, true, 
				function(req){
					Message.hide("msg-reject-translation-processing");
					var result = req.getResponseHeader("result");
					if(result == 1){
						Message.show("msg-reject-translation-result", 400, "處理成功", "案件已成功退件", Button.buttonReload);
					}else{
						Message.show("msg-reject-translation-result", 400, "處理失敗", "請稍後重試或聯絡客服", Message.BUTTON_OK);
					}
				}
			);
		}
		
		Message.show(
			"msg-reject-translation-confirm", 500, "確認案件退件", 
			"是否確定退件？<br/>一旦退件，將無法取得全部譯文，但案件尾款將退還給您。",
			new Message.Button("確定", reject), Message.BUTTON_CANCEL
		);
	},	
	//接案者放棄案件
	abandonTask:function(taskId){
		if(!taskId){
			return;
		}
		
		var abandon = function(){
			Message.show("msg-abandon-task-processing", 400, "系統處理中", Ajax.loadingImg);
			Ajax.sendRequest(
				"post", "/exe/member/AbandonTask", "id=" + taskId, true, 
				function(req){
					Message.hide("msg-abandon-task-processing");
					var result = req.getResponseHeader("result");
					if(result == 1){
						Message.show("msg-abandon-task-result", 400, "處理成功", "已放棄此案件", Button.buttonReload);
					}else{
						Message.show("msg-abandon-task-result", 400, "處理失敗", "請稍後重試或聯絡客服", Message.BUTTON_OK);
					}
				}
			);
		}
		
		Message.show(
			"msg-abandon-task-confirm", 400, "確認放棄案件", 
			"是否確定放棄案件？<br/>一旦放棄案件，您將無法獲得任何款項。",
			new Message.Button("確定", abandon), Message.BUTTON_CANCEL
		);
	},	
	//評價案件
	showEvaluate:function(tid, uType, user){
		var evaluateConfirm = function(){
			var evaluate = function(){
				Message.show("msg-evaluate-processing", 400, "系統處理中", Ajax.loadingImg);
				if(this.uType == "employer"){
					Ajax.sendRequest(
						"post", "/exe/member/EvaluateEmployer", "id=" + this.tid + "&score=" + this.score, true, 
						function(req){
							Message.hide("msg-evaluate-processing");
							var result = req.getResponseHeader("result");
							if(result == 1){
								Message.show(
									"msg-evaluate-result", 400, "處理成功", "已成功評價", Button.buttonReload);
							}else{
								Message.show(
									"msg-evaluate-result", 400, "處理失敗", "請稍後重試或聯絡客服", Message.BUTTON_OK);
							}
						}
					);
				}else if(this.uType == "translator"){
					Ajax.sendRequest(
						"post", "/exe/member/EvaluateTranslator", "id=" + this.tid + "&score=" + this.score, true, 
						function(req){
							Message.hide("msg-evaluate-processing");
							var result = req.getResponseHeader("result");
							if(result == 1){
								Message.show(
									"msg-evaluate-result", 400, "處理成功", "已成功評價", Button.buttonReload);
							}else{
								Message.show(
									"msg-evaluate-result", 400, "處理失敗", "請稍後重試或聯絡客服", Message.BUTTON_OK);
							}
						}
					);
				}
			}
			if(this.uType == "employer"){
				Message.show(
					"msg-evaluate-confirm", 400, "確認評價", 
					"您確定要給予此案主 " + this.number + " 顆星的評價嗎？<br/>評價一旦送出即不可再更改。", 
					new Message.Button("確定", evaluate, false, {tid:this.tid, score:this.number, uType:this.uType}), 
					Message.BUTTON_CANCEL
				);
			}else if(uType == "translator"){
				Message.show(
					"msg-evaluate-confirm", 400, "確認評價", 
					"您確定要給予此譯者 " + this.number + " 顆星的評價嗎？<br/>評價一旦送出即不可再更改。", 
					new Message.Button("確定", evaluate, false, {tid:this.tid, score:this.number, uType:this.uType}), 
					Message.BUTTON_CANCEL
				);
			}
		};
		
		var scores = Utility.createElement("div", null, {marginTop:"20px"}, null);
		for(i = 1; i <= 5; i++){
			var star = Utility.createElement(
				"img", {id:"star-" + i, number:i, uType:uType, tid:tid, src:"/image/star-0.png"}, null, 
				{onclick:evaluateConfirm, 
				 onmouseover:function(){
					for(i = 1; i <= this.number; i++){
						document.getElementById("star-" + i).src = "/image/star-2.png";
					}
				 }, 
				 onmouseout:function(){
					for(i = 1; i <= 5; i++){
						document.getElementById("star-" + i).src = "/image/star-0.png";
					}
				 }
				}, 
				scores
			);
		}
		if(uType == "employer"){
			Message.show("msg-evaluate", 400, "評價案主：" + user, scores, Message.BUTTON_CANCEL);
		}else if(uType == "translator"){
			Message.show("msg-evaluate", 400, "評價譯者：" + user, scores, Message.BUTTON_CANCEL);
		}
	},	
	//開啟案件留言視窗
	popup:function(url, id){
		if(!url){
			return;
		}
		
		var width = 600;
		var height = 600;
		var left = (window.innerWidth - width) / 2;
		var top = (window.innerHeight - height) / 2;
		if(id){
			window.open(
				url + "?id=" + id, "_blank", 
				"width=" + width + ",height=" + height + ",left=" + left + ",top=" + top
					+ ",menubar=no,status=no,toolbar=no,scrollbars=yes"
			);
		}else{
			window.open(
				url, "_blank", 
				"width=" + width + ",height=" + height + ",left=" + left + ",top=" + top
					+ ",menubar=no,status=no,toolbar=no,scrollbars=yes"
			);
		}
	},
	//新增討論
	createDiscussion:function(form){
		if(form.content.value == ""){
			Message.show("msg-wrong-format", 400, "格式錯誤", "請填寫訊息內容", Message.BUTTON_OK);
			return;
		}
		if(form.content.value.length > 255){
			Message.show("msg-wrong-format", 400, "格式錯誤", "訊息內容不得超過 255 字元", Message.BUTTON_OK);
			return;
		}
		if(form.tid.value == ""){
			Message.show("msg-wrong-format", 400, "系統錯誤", "請稍後重試或聯絡客服", Message.BUTTON_OK);
			return;
		}
		
		Message.show("msg-discussion-create-processing", 400, "系統處理中", Ajax.loadingImg);
		Ajax.sendRequest(
			"post", "/exe/member/CreateDiscussion", 
			"task_id=" + form.tid.value + "&content=" + encodeURIComponent(form.content.value), true, 
			function(req){
				Message.hide("msg-discussion-create-processing");
				var result = req.getResponseHeader("result");
				if(result == "true"){
					Message.show("msg-discussion-create-result", 400, "處理成功", "您的訊息已成功張貼", Button.buttonReload);
				}else{
					Message.show("msg-discussion-create-result", 400, "處理失敗", "請稍後重試或聯絡客服", Message.BUTTON_OK);
				}
			}
		);
	},
	//新增問與答
	createQuestion:function(form){
		if(form.content.value == ""){
			Message.show("msg-wrong-format", 400, "格式錯誤", "請填寫訊息內容", Message.BUTTON_OK);
			return;
		}
		if(form.content.value.length > 255){
			Message.show("msg-wrong-format", 400, "格式錯誤", "訊息內容不得超過 255 字元", Message.BUTTON_OK);
			return;
		}
		if(form.tid.value == ""){
			Message.show("msg-wrong-format", 400, "系統錯誤", "請稍後重試或聯絡客服", Message.BUTTON_OK);
			return;
		}
		
		Message.show("msg-question-create-processing", 400, "系統處理中", Ajax.loadingImg);
		Ajax.sendRequest(
			"post", "/exe/member/CreateQuestion", 
			"task_id=" + form.tid.value + "&content=" + encodeURIComponent(form.content.value), true, 
			function(req){
				Message.hide("msg-question-create-processing");
				var result = req.getResponseHeader("result");
				if(result == "true"){
					Message.show("msg-question-create-result", 400, "處理成功", "您的問題已成功張貼", Button.buttonReload);
				}else{
					Message.show("msg-question-create-result", 400, "處理失敗", "請稍後重試或聯絡客服", Message.BUTTON_OK);
				}
			}
		);
	},
	//回應問與答
	answerQuestion:function(form){
		if(form.content.value == ""){
			Message.show("msg-wrong-format", 400, "格式錯誤", "請填寫訊息內容", Message.BUTTON_OK);
			return;
		}
		if(form.content.value.length > 255){
			Message.show("msg-wrong-format", 400, "格式錯誤", "訊息內容不得超過 255 字元", Message.BUTTON_OK);
			return;
		}
		if(form.qid.value == ""){
			Message.show("msg-wrong-format", 400, "系統錯誤", "請稍後重試或聯絡客服", Message.BUTTON_OK);
			return;
		}
		
		Message.show("msg-question-answer-processing", 400, "系統處理中", Ajax.loadingImg);
		Ajax.sendRequest(
			"post", "/exe/member/AnswerQuestion", 
			"id=" + form.qid.value + "&answer=" + encodeURIComponent(form.content.value), true, 
			function(req){
				Message.hide("msg-question-answer-processing");
				var result = req.getResponseHeader("result");
				if(result == "1"){
					Message.show("msg-question-answer-result", 400, "處理成功", "您的回應已成功張貼", Button.buttonReload);
				}else{
					Message.show("msg-question-answer-result", 400, "處理失敗", "請稍後重試或聯絡客服", Message.BUTTON_OK);
				}
			}
		);
	},
	//邀請使用者接案
	inviteTranslator:function(tid, uid, span){
		if(!tid || !uid){
			return;
		}
	
		Message.show("msg-invite-translator-processing", 400, "系統處理中", Ajax.loadingImg);
		Ajax.sendRequest(
			"post", "/exe/member/InviteTranslator", "id=" + tid + "&translator=" + uid, true, 
			function(req){
				Message.hide("msg-invite-translator-processing");
				var result = req.getResponseHeader("result");
				if(result == "true"){
					Message.show("msg-invite-translator-result", 400, "處理成功", "您已成功寄出邀請訊息", Message.BUTTON_OK);
					span.className = "tag bottom blue mark-gray";
					span.onclick = null;
					span.innerHTML = "已邀請接案";
				}else{
					Message.show("msg-invite-translator-result", 400, "處理失敗", "請稍後重試或聯絡客服", Message.BUTTON_OK);
				}
			}
		);
	},
	//邀請使用者評價
	inviteEvaluation:function(tid, span){
		if(!tid){
			return;
		}
	
		Message.show("msg-invite-evaluation-processing", 400, "系統處理中", Ajax.loadingImg);
		Ajax.sendRequest(
			"post", "/exe/member/InviteEvaluation", "id=" + tid, true, 
			function(req){
				Message.hide("msg-invite-evaluation-processing");
				var result = req.getResponseHeader("result");
				if(result == "true"){
					Message.show("msg-invite-evaluation-result", 400, "處理成功", "您已成功寄出邀請評價訊息", Message.BUTTON_OK);
					span.className = "tag bottom mark-gray";
					span.onclick = null;
					span.innerHTML = "已邀請評價";
				}else{
					Message.show("msg-invite-evaluation-result", 400, "處理失敗", "請稍後重試或聯絡客服", Message.BUTTON_OK);
				}
			}
		);
	},
	//申訴
	createAbuseReport:function(type, target, tool){
		if(!type || !target){
			return;
		}
	
		var send = function(){
			Message.hide("msg-abuse-report-confirm");
			Message.show("msg-abuse-report-processing", 400, "系統處理中", Ajax.loadingImg);
			Ajax.sendRequest(
				"post", "/exe/member/CreateAbuseReport", "type=" + type + "&target=" + target, true, 
				function(req){
					Message.hide("msg-abuse-report-processing");
					var result = req.getResponseHeader("result");
					if(result == "true"){
						Message.show(
							"msg-abuse-report-result", 400, "處理成功", "您已成功提出申訴，站務人員將盡快處理。", 
							Message.BUTTON_OK
						);
						tool.className = "tag bottom green mark-gray";
						tool.onclick = null;
						tool.innerHTML = "您已提出申訴";
					}else{
						Message.show("msg-abuse-report-result", 400, "處理失敗", "請稍後重試或聯絡客服", Message.BUTTON_OK);
					}
				}
			);
		}
		
		Message.show(
			"msg-abuse-report-confirm", 400, "確認申訴", 
			"是否確定申訴？<br/>本站接到您的申訴後，將仔細審閱此案件，<br/>並視情況決定是否退還尾款給您。",
			new Message.Button("確定", send), Message.BUTTON_CANCEL
		);
	}
}